#include <math.h>
#include <stdlib.h>
#include <stdio.h>

/*****************************************************************
 
    This file is part of the eqtools package.

    EqTools is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    EqTools is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with EqTools.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2013 Ian C. Faust

******************************************************************/

int A[64][64] = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,-20,16,-4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-4,12,-12,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-4,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
		 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,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20,0,-20,0,-16,0,16,0,4,0,-4,0,2,0,-2,0,-5,0,5,0,4,0,-4,0,-1,0,1,0}, 
		 {8,-20,16,-4,-20,50,-40,10,16,-40,32,-8,-4,10,-8,2,-20,50,-40,10,50,-125,100,-25,-40,100,-80,20,10,-25,20,-5,16,-40,32,-8,-40,100,-80,20,32,-80,64,-16,-8,20,-16,4,-4,10,-8,2,10,-25,20,-5,-8,20,-16,4,2,-5,4,-1}, 
		 {-4,12,-12,4,10,-30,30,-10,-8,24,-24,8,2,-6,6,-2,10,-30,30,-10,-25,75,-75,25,20,-60,60,-20,-5,15,-15,5,-8,24,-24,8,20,-60,60,-20,-16,48,-48,16,4,-12,12,-4,2,-6,6,-2,-5,15,-15,5,4,-12,12,-4,-1,3,-3,1}, 
		 {0,-4,0,0,0,12,0,0,0,-12,0,0,0,4,0,0,0,10,0,0,0,-30,0,0,0,30,0,0,0,-10,0,0,0,-8,0,0,0,24,0,0,0,-24,0,0,0,8,0,0,0,2,0,0,0,-6,0,0,0,6,0,0,0,-2,0,0}, 
		 {2,0,-2,0,-6,0,6,0,6,0,-6,0,-2,0,2,0,-5,0,5,0,15,0,-15,0,-15,0,15,0,5,0,-5,0,4,0,-4,0,-12,0,12,0,12,0,-12,0,-4,0,4,0,-1,0,1,0,3,0,-3,0,-3,0,3,0,1,0,-1,0}, 
		 {-4,10,-8,2,12,-30,24,-6,-12,30,-24,6,4,-10,8,-2,10,-25,20,-5,-30,75,-60,15,30,-75,60,-15,-10,25,-20,5,-8,20,-16,4,24,-60,48,-12,-24,60,-48,12,8,-20,16,-4,2,-5,4,-1,-6,15,-12,3,6,-15,12,-3,-2,5,-4,1}, 
		 {2,-6,6,-2,-6,18,-18,6,6,-18,18,-6,-2,6,-6,2,-5,15,-15,5,15,-45,45,-15,-15,45,-45,15,5,-15,15,-5,4,-12,12,-4,-12,36,-36,12,12,-36,36,-12,-4,12,-12,4,-1,3,-3,1,3,-9,9,-3,-3,9,-9,3,1,-3,3,-1}, 
		 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2, 0,-2, 0,-2, 0, 2, 0,-2, 0, 2, 0,-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0},
{-12,12,12,-12,12,-12,-12,12,-8,-4, 8, 4, 8, 4,-8,-4,-6, 6,-6, 6, 6,-6, 6,-6,-6, 6, 6,-6,-6, 6, 6,-6,-4,-2,-4,-2, 4, 2, 4, 2,-4,-2, 4, 2,-4,-2, 4, 2,-3, 3,-3, 3,-3, 3,-3, 3,-2,-1,-2,-1,-2,-1,-2,-1},
{ 8,-8,-8, 8,-8, 8, 8,-8, 4, 4,-4,-4,-4,-4, 4, 4, 4,-4, 4,-4,-4, 4,-4, 4, 4,-4,-4, 4, 4,-4,-4, 4, 2, 2, 2, 2,-2,-2,-2,-2, 2, 2,-2,-2, 2, 2,-2,-2, 2,-2, 2,-2, 2,-2, 2,-2, 1, 1, 1, 1, 1, 1, 1, 1}};

double factorial[4] = {1.0,1.0,2.0,6.0}; /* value needed for derivatives, and a lookup table is the easiest/fastest method */

int clip(int x, int a)
{ /* use of a set of ternary operators to bound a value x between 0 and a */
  return x > a - 1 ? a - 1 : (x < 0 ? 0 : x);
}


int ismonotonic(double val[], int ix)
{   /* while loop based check of monotonicity,
       so on very large bases that fail, it 
       stops early. Starts at end.  */
  int counter = ix - 1,output = 1;
  
  while( counter )
    { counter--;  
      if(val[counter] - val[counter + 1] > 0)
	{
	  counter = 0;
	  output = 0;
	}
    }
  return output;
}


int isregular(double val[], int ix)
{   /* while loop based check of monotonicity,
       so on very large bases that fail, it 
       stops early. Starts at end.  */
  int counter = ix - 2,output = 1;
  double eps = 1e-6; /* Difference between values within .001%  */
  double temp = val[counter] - val[counter + 1];
  while( counter )
    { counter--;
      if(abs((val[counter] - val[counter + 1])/temp - 1) >= eps)
	{
	  counter = 0;
	  output = 0;
	}
    }
  return output;
}


int ijk2n(int i, int j, int k)
{
  return(i+4*j+16*k);
}

double tricubic_eval_full(double a[64], double x, double y, double z, double multi, int dx, int dy, int dz)
{
  int i,j,k;
  double ret=(double)(0.0);
  double factx, facty, factz;
  
  /* TRICUBIC EVAL FULL
     It is used to compute the value of the function or derivative at a given point (x,y,z).
     The extra arguments, dx, dy, dz give the order of the derivative in that direction.
     multi is the scaling multiplier needed so that the proper scaling can be applied.
  */
  
  for (i=dx;i<4;i++)
    { factx = factorial[i]/factorial[i-dx];
      for (j=dy;j<4;j++) 
	{ facty = factx*factorial[j]/factorial[j-dy];
	  for (k=dz;k<4;k++) 
	    { factz = facty*factorial[k]/factorial[k-dz];
	      ret+=factz*multi*a[ijk2n(i, j, k)]*pow(x, i-dx)*pow(y, j-dy)*pow(z, k-dz); /* needs factorial inclusion */
	    }
	}
    }
  return(ret);
}


double tricubic_eval(double a[64], double x, double y, double z)
{
  int i,j,k;
  double ret=(double)(0.0);
  /* TRICUBIC EVAL
     This is the short version of tricubic_eval. It is used to compute
     the value of the function at a given point (x,y,z). To compute
     partial derivatives of f, use the full version with the extra args.
  */
  for (i=0;i<4;i++)
    {
      for (j=0;j<4;j++) 
	{
	  for (k=0;k<4;k++) 
	    {
	      ret+=a[ijk2n(i, j, k)]*pow(x, i)*pow(y, j)*pow(z, k);
	    }
	}
    }
  return(ret);
}


int _compare_fun(const void* a, const void* b)
{
  return (**(int**)a - **(int**)b);
}


int _bin_double(const void* a, const void* b)
{ double b0,b1;
  b0 = (*(double*)a - *(double*)b);
  b1 = (*(double*)a - *((double*)b+1));
  return (int)(((b0 >= 0) - (b0 < 0)) + ((b1 >= 0) - (b1 < 0)));
}


void int_argsort(int outvec[], int invec[], int len)
{ int i;
  int** temp = malloc(len * sizeof(int*));
  /* temp is constructed to reference invec, temp will
     be the modified order. outvec is the difference
     from the start to provide indices for other matricies*/
  for(i=0; i<len; i++)
    {
      temp[i] = &invec[i];
    }

  qsort(temp, len, sizeof(int*), _compare_fun);
  for(i=0; i<len; i++)
    {
      outvec[i] = (int)(temp[i] - &invec[0]);
    }
  free(temp);
}


void voxel(double fin[], double f[], int tempx0, int tempx1, int tempx2, int ix0, int ix1, int ix2)
{
  int findx, l, k, j, templ, tempk, tempj;
  findx = 0;
  
  for(j = tempx2 - 1; j < tempx2 + 3; j++)
    {
      tempj = clip(j,ix2);
      for(k = tempx1 - 1; k < tempx1 + 3; k++)
	{ 
	  tempk = clip(k,ix1);
	  for(l = tempx0 - 1; l < tempx0 + 3; l++)
	    {
	      templ = clip(l,ix0);
	      fin[findx] = *(f + templ + ix0*(tempk + ix1*tempj));
	      findx++;
	    }
	}	  
    }
} 


void _nonreg_x_construct(double val[], double inmat[], int shape[])
{
  int k,j,i,idx0,idx1,gap0,gap1;
  gap0 = shape[0] - 2;
  gap1 = (shape[1]-2)*shape[0];
  idx0 = 0;
  idx1 = 0;
  
  for(k=0;k<2;k++)
    {
      for(j=0;j<2;j++)
	{
	  for(i=0;i<2;i++)
	    {
	      val[idx1] = inmat[idx0];
	      //printf(" %f %f %i %i \n",val[idx1],inmat[idx0],idx0,idx1);
	      idx1++;
	      idx0++;
	    }
	  idx0 = idx0 + gap0;
	}
      idx0 = idx0 + gap1;				    
    }
  //printf(" \n");
}


void tridiff(double outmat[], double inmat[], double x[4], int shapeout[3], int shapein[3], int dim, double spacing)
{
  /*outmat is the matrix reduced by 2 (derivatives calculated along same base or centered)
   dimension of derivative is specified by 'dim', the shape of the input array is described by
   'shape'. The arrays are always three dimensional (hence tridiff HARDCODED). Positions along
   derivative axis specified by 'x' and will have length 4 in inmat, and 2 in the outmat.  Other
  dimensions are variable and sized accoriding to the discrepancy as shown by the difference 
  of shapeout and shapein*/

  /*x0,x1,and x2 represent some sort of einstein notation, where the iteration
   follows a similar convention to the levi-civita symbol*/
  int x0,x1,x2,idx,gap,gap0,gap1,ixin,ixout,x0lim,x1lim,x2lim;
  x0lim = shapeout[0];
  x1lim = shapeout[1];
  x2lim = shapeout[2];
  ixout = 0;

  if(dim == 0)
    {
      gap = 1;
    }
  else if(dim == 1)
    {
      gap = shapein[0];
    }
  else
    {
      gap = shapein[0]*shapein[1];
    }

  gap0 = shapein[0] - x0lim;
  gap1 = (shapein[1] - x1lim)*shapein[0];
  ixin = (gap0 + gap1 + (shapein[0]*shapein[1])*(shapein[2] - x2lim))/2;

  
  for(x2=0; x2<x2lim; x2++)
    {
      for(x1=0; x1<x1lim; x1++)
	{
	  for(x0=0; x0<x0lim; x0++)
	    { 
	      idx = ixin/gap % 4;
	      outmat[ixout] = spacing*(inmat[ixin + gap] - inmat[ixin - gap])/(x[idx + 1] - x[idx - 1]);
	      ixout++;
	      ixin++;
	    }
	  ixin = ixin + gap0;
	}
      ixin = ixin + gap1;
    }
}


void _gen_nonreg_x(double val[], double f[], double x0[4], double x1[4], double x2[4])
{ /*initialize necessary derivatives */
  double dx0gap, dx1gap, dx2gap;
  double dfdx0[32];//[2][4][4];
  double dfdx1[16];//[2][2][4];
  double dfdx2[8];//[2][2][2];
  double dfdx01[16];//[2][2][4];
  double dfdx12[8];//[2][2][2];
  double dfdx02[8];//[2][2][2];
  double dfdx012[8];//[2][2][2];
  /* i think i need to modify tridiff to intelligently deal with the different sizes  */

  dx0gap = x0[2]-x0[1];
  dx1gap = x1[2]-x1[1];
  dx2gap = x2[2]-x2[1];
   
  int in[3] = {4,4,4};
  
  _nonreg_x_construct(&val[0],&f[21],in);
 
  int out[3] = {2,4,4};
 
  /* x0 derivative */
  tridiff(dfdx0, f, x0, out, in, 0, dx0gap);
  _nonreg_x_construct(&val[8], &dfdx0[10], out);

  /* x1 derivative */
  out[1] = 2;

  tridiff(dfdx1, f, x1, out, in, 1, dx1gap);
  _nonreg_x_construct(&val[16], &dfdx1[4], out);
  
  in[0] = 2;
  tridiff(dfdx01, dfdx0, x1, out, in, 1, dx1gap);
  _nonreg_x_construct(&val[32], &dfdx01[4], out);

  /* x2 derivative */
  out[2] = 2;
 
  in[0] = 4;
  tridiff(dfdx2, f, x2, out, in, 2, dx2gap);
  _nonreg_x_construct(&val[24], &dfdx2[0], out);  
  
  in[0] = 2;
  tridiff(dfdx02, dfdx0, x2, out, in, 2, dx2gap);
  _nonreg_x_construct(&val[40], &dfdx02[0], out);    

  in[1] = 2;
  tridiff(dfdx12, dfdx1, x2, out, in, 2, dx2gap);
  _nonreg_x_construct(&val[48], &dfdx12[0], out);
  
  tridiff(dfdx012, dfdx01, x2, out, in, 2, dx2gap);
  _nonreg_x_construct(&val[56], &dfdx012[0], out);    
}


void tricubic_get_coeff_stacked(double a[64], double x[64])
{
  int i,j;
  for (i=0;i<64;i++) 
    {
      a[i]=(double)(0.0);
      for (j=0;j<64;j++) 
	{
	  a[i]+=A[i][j]*x[j];
	}
      a[i] = a[i]/8; /* A is the combination of A_v2 and the proper derivative operator as ints (requires a division by 8)  */
      //printf(" %f %i \n",a[i],i);
    }
}


void tricubic_get_coeff_stacked_nonreg(double a[64], double f[64], double fx0[], double fx1[], double fx2[])
{
  int i,j;
  double x[64];

  _gen_nonreg_x(x, f, fx0, fx1, fx2);

  for (i=0;i<64;i++) 
    { 
      a[i]=(double)(0.0);
      for (j=0;j<64;j++) 
	{
	  a[i]+=A_v2[i][j]*x[j];
	}
    }
}


void nonreg_ev(double val[], double x0[], double x1[], double x2[], double f[], double fx0[], double fx1[], double fx2[], int ix0, int ix1, int ix2, int ix)
{
  int i,iter = -1,loc;
  double fin[64],a[64], dx0gap, dx1gap, dx2gap;
  
  int* tempx0 = malloc(ix*sizeof(int));
  int* tempx1 = malloc(ix*sizeof(int));
  int* tempx2 = malloc(ix*sizeof(int));
  int* pos = malloc(ix*sizeof(int));
  int* indx = malloc(ix*sizeof(int));

  /* solve for indexes */
  for(i=0;i<ix;i++)
    { /* I had to add a subtraction to the nitems of the bsearch to get the upper boundary to respond properly, which fixes the boundary
	 error listed underneath*/
      tempx0[i] = clip((int)((double*) bsearch(&x0[i], fx0, ix0-1, sizeof(double), _bin_double) - &fx0[0]), ix0);
      tempx1[i] = clip((int)((double*) bsearch(&x1[i], fx1, ix1-1, sizeof(double), _bin_double) - &fx1[0]), ix1);
      tempx2[i] = clip((int)((double*) bsearch(&x2[i], fx2, ix2-1, sizeof(double), _bin_double) - &fx2[0]), ix2);
      /* bounds checking required here, modify in* values, subtle boundary error here that I will need to come back to */
     
      pos[i] = tempx0[i] + ix0*(tempx1[i] + ix1*tempx2[i]); 
    }
  int_argsort(indx, pos, ix);

  for(i=0;i < ix; i++)
    {
      
      /* generate matrix for input into interp, this
       is the first attempt at trying to speed up the 
      equation by forcing it more onto the C side*/
      loc = indx[i];
      if(iter != pos[loc])
	{
	  iter = pos[loc];
	  voxel(fin, f, tempx0[loc], tempx1[loc], tempx2[loc], ix0, ix1, ix2);
	  tricubic_get_coeff_stacked_nonreg(a, fin, &fx0[tempx0[loc]-1], &fx1[tempx1[loc]-1], &fx2[tempx2[loc]-1]);

	  dx0gap = fx0[tempx0[loc]+1] - fx0[tempx0[loc]];
	  dx1gap = fx1[tempx1[loc]+1] - fx1[tempx1[loc]];
	  dx2gap = fx2[tempx2[loc]+1] - fx2[tempx2[loc]];	  
	}
      
      val[loc] = tricubic_eval(a,
			       (x0[loc] - fx0[tempx0[loc]])/dx0gap,
			       (x1[loc] - fx1[tempx1[loc]])/dx1gap,
			       (x2[loc] - fx2[tempx2[loc]])/dx2gap);
    }

  /*generate pos and loc */

  free(tempx0);
  free(tempx1);
  free(tempx2);
  free(pos);
  free(indx);

}


void nonreg_ev_full(double val[], double x0[], double x1[], double x2[], double f[], double fx0[], double fx1[], double fx2[], int ix0, int ix1, int ix2, int ix, int d0, int d1, int d2)
{
  int i,iter = -1,loc;
  double fin[64],a[64], dx0gap, dx1gap, dx2gap, multi;
  
  
  int* tempx0 = malloc(ix*sizeof(int));
  int* tempx1 = malloc(ix*sizeof(int));
  int* tempx2 = malloc(ix*sizeof(int));
  int* pos = malloc(ix*sizeof(int));
  int* indx = malloc(ix*sizeof(int));

  /* solve for indexes */
  for(i=0;i<ix;i++)
    { /* I had to add a subtraction to the nitems of the bsearch to get the upper boundary to respond properly, which fixes the boundary
	 error listed underneath*/
      tempx0[i] = clip((int)((double*) bsearch(&x0[i], fx0, ix0-1, sizeof(double), _bin_double) - &fx0[0]), ix0);
      tempx1[i] = clip((int)((double*) bsearch(&x1[i], fx1, ix1-1, sizeof(double), _bin_double) - &fx1[0]), ix1);
      tempx2[i] = clip((int)((double*) bsearch(&x2[i], fx2, ix2-1, sizeof(double), _bin_double) - &fx2[0]), ix2);
      /* bounds checking required here, modify in* values, subtle boundary error here that I will need to come back to */
     
      pos[i] = tempx0[i] + ix0*(tempx1[i] + ix1*tempx2[i]); 
    }
  int_argsort(indx, pos, ix);

  for(i=0;i < ix; i++)
    {
      
      /* generate matrix for input into interp, this
       is the first attempt at trying to speed up the 
      equation by forcing it more onto the C side*/
      loc = indx[i];
      if(iter != pos[loc])
	{
	  iter = pos[loc];
	  voxel(fin, f, tempx0[loc], tempx1[loc], tempx2[loc], ix0, ix1, ix2);
	  tricubic_get_coeff_stacked_nonreg(a, fin, &fx0[tempx0[loc]-1], &fx1[tempx1[loc]-1], &fx2[tempx2[loc]-1]);

	  dx0gap = fx0[tempx0[loc]+1] - fx0[tempx0[loc]];
	  dx1gap = fx1[tempx1[loc]+1] - fx1[tempx1[loc]];
	  dx2gap = fx2[tempx2[loc]+1] - fx2[tempx2[loc]];
	  multi = pow(pow(dx0gap, d0)*pow(dx1gap, d1)*pow(dx2gap, d2), -1);
	}
      
      val[loc] = tricubic_eval_full(a,
			       (x0[loc] - fx0[tempx0[loc]])/dx0gap,
			       (x1[loc] - fx1[tempx1[loc]])/dx1gap,
			       (x2[loc] - fx2[tempx2[loc]])/dx2gap,
			       multi,
			       d0,
			       d1,
			       d2);
    }

  /*generate pos and loc */

  free(tempx0);
  free(tempx1);
  free(tempx2);
  free(pos);
  free(indx);

}



void reg_ev(double val[], double x0[], double x1[], double x2[], double f[], double fx0[], double fx1[], double fx2[], int ix0, int ix1, int ix2, int ix)
{
  int i, iter=-1, loc;
  double dx0gap, dx1gap, dx2gap, temp, a[64], fin[64];
  double* dx0 = malloc(ix*sizeof(double));
  double* dx1 = malloc(ix*sizeof(double));
  double* dx2 = malloc(ix*sizeof(double));    
  double* tempx0 = malloc(ix*sizeof(double));
  double* tempx1 = malloc(ix*sizeof(double));
  double* tempx2 = malloc(ix*sizeof(double));
  int* pos = malloc(ix*sizeof(int));
  int* indx = malloc(ix*sizeof(int));
  
  dx0gap = fx0[1] - fx0[0];
  dx1gap = fx1[1] - fx1[0];
  dx2gap = fx2[1] - fx2[0];
  
  /*generate indices*/
  for(i=0;i<ix;i++)
    {
      temp = (x0[i] - fx0[0])/dx0gap;
      dx0[i] = modf(temp, &tempx0[i]);
      tempx0[i] = (double)clip((int)tempx0[i], ix0);
      dx0[i] = temp - tempx0[i];
      
      temp = (x1[i] - fx1[0])/dx1gap;
      dx1[i] = modf(temp, &tempx1[i]);
      tempx1[i] = (double)clip((int)tempx1[i], ix1);
      dx1[i] = temp - tempx1[i];
      
      temp = (x2[i] - fx2[0])/dx2gap;
      dx2[i] = modf(temp, &tempx2[i]);
      tempx2[i] = (double)clip((int)tempx2[i], ix2);
      dx2[i] = temp - tempx2[i];

      pos[i] = (int)tempx0[i] + ix0*((int)tempx1[i] + ix1*((int)tempx2[i]));
      
    }

  // find the right order for the evaluation to try and save time
  int_argsort(indx, pos, ix);

  for(i=0;i < ix; i++)
    {
      
      /* generate matrix for input into interp, this
       is the first attempt at trying to speed up the 
      equation by forcing it more onto the C side*/
      loc = indx[i];
      if(iter != pos[loc])
	{
	  iter = pos[loc];
	  voxel(fin, f, (int)tempx0[i], (int)tempx1[i], (int)tempx2[i], ix0, ix1, ix2);
	  tricubic_get_coeff_stacked(a,fin);
	}
      val[loc] = tricubic_eval(a, dx0[loc], dx1[loc], dx2[loc]);
    }
 
  free(dx0);
  free(dx1);
  free(dx2);
  free(pos);
  free(indx);
  free(tempx0);
  free(tempx1);
  free(tempx2);
}


void reg_ev_full(double val[], double x0[], double x1[], double x2[], double f[], double fx0[], double fx1[], double fx2[], int ix0, int ix1, int ix2, int ix, int d0, int d1, int d2)
{
  int i, iter=-1, loc;
  double dx0gap, dx1gap, dx2gap, temp, multi, a[64], fin[64];
  double* dx0 = malloc(ix*sizeof(double));
  double* dx1 = malloc(ix*sizeof(double));
  double* dx2 = malloc(ix*sizeof(double));    
  double* tempx0 = malloc(ix*sizeof(double));
  double* tempx1 = malloc(ix*sizeof(double));
  double* tempx2 = malloc(ix*sizeof(double));
  int* pos = malloc(ix*sizeof(int));
  int* indx = malloc(ix*sizeof(int));
  
  dx0gap = fx0[1] - fx0[0];
  dx1gap = fx1[1] - fx1[0];
  dx2gap = fx2[1] - fx2[0];
  multi = pow(pow(dx0gap, d0)*pow(dx1gap, d1)*pow(dx2gap, d2), -1);

  
  /*generate indices*/
  for(i=0;i<ix;i++)
    {
      temp = (x0[i] - fx0[0])/dx0gap;
      dx0[i] = modf(temp, &tempx0[i]);
      tempx0[i] = (double)clip((int)tempx0[i], ix0);
      dx0[i] = temp - tempx0[i];
      
      temp = (x1[i] - fx1[0])/dx1gap;
      dx1[i] = modf(temp, &tempx1[i]);
      tempx1[i] = (double)clip((int)tempx1[i], ix1);
      dx1[i] = temp - tempx1[i];
      
      temp = (x2[i] - fx2[0])/dx2gap;
      dx2[i] = modf(temp, &tempx2[i]);
      tempx2[i] = (double)clip((int)tempx2[i], ix2);
      dx2[i] = temp - tempx2[i];

      pos[i] = (int)tempx0[i] + ix0*((int)tempx1[i] + ix1*((int)tempx2[i]));
      
    }

  // find the right order for the evaluation to try and save time
  int_argsort(indx, pos, ix);

  for(i=0;i < ix; i++)
    {
      
      /* generate matrix for input into interp, this
       is the first attempt at trying to speed up the 
      equation by forcing it more onto the C side*/
      loc = indx[i];
      if(iter != pos[loc])
	{
	  iter = pos[loc];
	  voxel(fin, f, (int)tempx0[i], (int)tempx1[i], (int)tempx2[i], ix0, ix1, ix2);
	  tricubic_get_coeff_stacked(a,fin);
	}
      val[loc] = tricubic_eval_full(a, dx0[loc], dx1[loc], dx2[loc], multi, d0, d1, d2);
    }
 
  free(dx0);
  free(dx1);
  free(dx2);
  free(pos);
  free(indx);
  free(tempx0);
  free(tempx1);
  free(tempx2);
}



void ev(double val[], double x0[], double x1[], double x2[], double f[], double fx0[], double fx1[], double fx2[], int ix0, int ix1, int ix2, int ix)
{ 
  if(isregular(fx0, ix0) && isregular(fx1, ix1) && isregular(fx2, ix2))
    {
      reg_ev(val, x0, x1, x2, f, fx0, fx1, fx2, ix0, ix1, ix2, ix);
    }
  else
    {
      nonreg_ev(val, x0, x1, x2, f, fx0, fx1, fx2, ix0, ix1, ix2, ix);
    }
} 
